package leetcode.medium.limit50;

/**
 * 盛最多水的容器
 *
 * @author yaoyao1.liu@zhaopin.com.cn
 * @since 2022-06-29 19:15
 **/
public class No11 {

    public static void main(String[] args) {
        No11 no11 = new No11();
        int[] ints = {1, 1};
        int maxArea = no11.maxArea(ints);
        System.out.println(maxArea);

    }

    public int maxArea(int[] height) {
        int length = height.length;
        if (length <= 1) {
            return 0;
        }
        int maxArea = 0;
        for (int i = 0; i < length - 1; i++) {
            int h = height[i];
            if (h > maxArea / (length - i - 1)) {
                for (int j = i + 1; j < length; j++) {
                    int h1 = height[j];
                    int area = (j - i) * Integer.max(h1, h);
                    maxArea = Integer.max(maxArea, area);
                }
            }
        }
        return maxArea;
    }
}
